<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    cors
    <script>
      var xhr = new XMLHttpRequest();
      xhr.onreadystatechange = function () {
          if(xhr.readyState !==4) return;
          const status=xhr.status;
          if(status>=200 && status<300 || status ===304){
              console.log("request success");
          }else{
              console.log("request error")
          }
      };
      xhr.open("GET", "http://localhost:9000", true);
      xhr.timeout = 0; // 设置超时时间,0表示永不超时
      // 设置期望的返回数据类型 'json' 'text' 'document' ...
      xhr.responseType = "";
      // 设置请求头
    //   xhr.setRequestHeader("", "");
      xhr.send();
    </script>
  </body>
</html>
